def fib(n):
    a, b = 1, 2
    while a + b < n :
        yield a + b
        a, b = b, a + b

lim = 4e6
#lim = 100
#print [x for x in fib(lim) if x % 2 ==0]
print 2 + sum([x for x in fib(lim) if x % 2 ==0])
